import Vue from 'vue'
import Vuex from 'vuex'
import state from './state'
import mutations from './mutations'
import getters from './getters'
import actions from './actions'
import createLogger from 'vuex/dist/logger'
Vue.use(Vuex)

const isDEV = process.env.NODE_ENV === 'development'

const store = new Vuex.Store({
  strict: isDEV,
  state,
  mutations,
  getters,
  actions,
  plugins: [createLogger()],
  modules: {
    a: {
      namespaced: true,
      state: {
        text: 1
      },
      mutations: {
        updateText (state, text) {
          console.log(state)
          state.text = text
        }
      },
      actions: {
        add ({ state, commit, rootState }) {
          commit('updateText', rootState.counter)
        }
      }
    },
    b: {
      state: {
        text: 2
      }
    }
  }
})

export default store
